package com.bobo.mall.search.controller;

import com.bobo.mall.search.service.MallSearchService;
import com.bobo.mall.search.vo.SearchParam;
import com.bobo.mall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @program: malll
 * @description:
 * @author: Mr.Xu
 * @create: 2021-02-01 23:23
 *
 **/
@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    /**
     * 将所有查询条件封装到指定对象
     * @param param
     * @return
     */
    @GetMapping("/list.html")
    public String listPage(SearchParam param, Model model){

        // 1、根据传递过来的参数到 es 中检索商品
        SearchResult result = mallSearchService.search(param);
        model.addAttribute("result",result);
        return "list";
    }


}